/*
 * adc.c
 *
 * Created: 17.09.2012 08:57:22
 *  Author: vegardvo
 */ 
#include <util/delay.h>
#include "definitions.h"

int adcDriver_read(int channel){
	volatile char *adc = (char *) 0x1500;
	_delay_us(WRITE_DELAY_US_);
	if(channel == 1)
	{
		adc[0] = 0x4;
		_delay_us(READ_DELAY_US_);
		return adc[0];
	}
	else if(channel == 2)
	{
		adc[0] = 0x5;
		_delay_us(READ_DELAY_US_);
		return adc[0];
	}
	else if (channel == 3)
	{
		adc[0] = 0x6;
		_delay_us(READ_DELAY_US_);
		return adc[0];
	}
	else if (channel == 4)
	{
		adc[0] = 0x7;
		_delay_us(READ_DELAY_US_);
		return adc[0];
	}
	else
	{
		return -1;
	}
}